﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using DevExpress.Web.ASPxClasses;	

public partial class pPlan : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (Session["Email"] != null)
                Master.UsuarioRegistrado(Session["Email"].ToString());
            lblIdPlandeServicio.Text = Request["IDPlanServicio"];
            CargarPlanes();
        }

        if (gvGrilla.IsCallback)
        {
            CargarPlanes();
        }
    }

    private void CargarPlanes()
    {
        List<PlanServicio> ListaPlanes  = PlanServicio.ObtenerTodos();
        gvGrilla.DataSource = ListaPlanes;
        gvGrilla.DataBind();
    }


    protected void btnNuevoUsuario_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("pPlanDeServicioModificar.aspx?IDPlanServicio=0");
    }


    protected void gvGrilla_CustomButtonCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomButtonCallbackEventArgs e)
    {
        PlanServicio oPlanServicio = (Entities.PlanServicio)(gvGrilla.GetRow(e.VisibleIndex));
        if (e.ButtonID == "Modificar")
            ASPxWebControl.RedirectOnCallback(String.Format("pPlanDeServicioModificar.aspx?IDPlanServicio={0}", oPlanServicio.IDPlanServicio));
        if (e.ButtonID == "Eliminar")
            ASPxWebControl.RedirectOnCallback(String.Format("pPlanDeServicioEliminar.aspx?IDPlanServicio={0}", oPlanServicio.IDPlanServicio));
    
    }



}